//package cn.edu.zut.graduate.intercept;
//
//import cn.edu.zut.graduate.supervisor.ServiceFit;
//import org.springframework.stereotype.Repository;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * Created by sky on 15/11/7.
// */
//@Repository
//public class PowerInterceptor implements HandlerInterceptor {
//
//    @Resource
//    private ServiceFit serviceFit;
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
////        String uri = request.getRequestURI();
////        Power power = (Power) serviceFit.getPowerService().findByUrl(uri).getResult();
////        System.out.println("测试---1"+serviceFit.getPowerService().findByUrl(uri).getResult());
////        if (power == null) {
////            power = new Power();
////            power.setPowerUrl(uri);
////            ResultDo resultDo = serviceFit.getPowerService().saveOrUpdateRight(power);
////            if (resultDo.isSuccess()) {
////                power = (Power) resultDo.getResult();
////            } else {
////                response.sendRedirect(request.getContextPath());
////                return false;
////            }
////        }
//
////        Role role = (Role) request.getSession().getAttribute("role");
////        if (role != null && ((role.getIndex() & power.getCommon()) != 0)) {
////            return true;
////        }else {
////            response.sendRedirect(request.getContextPath());
////            return false;
////        }
//        return true;
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//
//    }
//
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//
//    }
//}
